<?php
    require_once "../includes/functions.php";
    $user_id = check_cookie_auth();
    if ($user_id!==false) {
        $course_recs = get_course_recommendations($user_id,'array',3);
        if (!empty($course_recs)) {
            echo "<p class=\"rec-type\" style=\"background-color:#F175DE\">People on your course(s) viewed:</p>";
            foreach ($course_recs as $val) {
                $infostring = (!empty($val['ISSN'])?"ISSN: {$val['ISSN']}&nbsp;/&nbsp;":"").(!empty($val['DOI'])?"DOI: {$val['DOI']}&nbsp;/&nbsp;":"").(!empty($val['AN'])?"AN: {$val['AN']}":"");
                echo "<p class=\"search-result\"><a target=\"_blank\"".generate_link(ezproxy_url($val['link']))."><span class=\"pointer\" style=\"text-decoration:none;\">&#0187;</span>".ssreplace(ucwords(strtolower($val['name'])),38)."<br/>"
                . "<span style=\"text-decoration:none;\">$infostring&nbsp;</span></a></p>";
            }
        }
        $relationship_recs = get_relationship_recommendations($user_id,'array',3);
        if (!empty($relationship_recs)) {
            echo "<p class=\"rec-type\" style=\"background-color:#39E391\">Similar to your recently viewed articles:</p>";
            foreach ($relationship_recs as $val) {
                $infostring = (!empty($val['ISSN'])?"ISSN: {$val['ISSN']}&nbsp;/&nbsp;":"").(!empty($val['DOI'])?"DOI: {$val['DOI']}&nbsp;/&nbsp;":"").(!empty($val['AN'])?"AN: {$val['AN']}":"");
                echo "<p class=\"search-result\"><a target=\"_blank\"".generate_link(ezproxy_url($val['link']))."><span class=\"pointer\" style=\"text-decoration:none;\">&#0187;</span>".ssreplace(ucwords(strtolower($val['name'])),38)."<br/>"
                . "<span style=\"text-decoration:none;\">$infostring&nbsp;</span></a></p>";
            }
        }
        if (is_numeric($_GET['search-id'])) {
            $search_recs = get_search_recommendations($_GET['search-id'],'array',3);
            if (!empty($search_recs)) {
                echo "<p class=\"rec-type\" style=\"background-color:#39B9E3\">Related to your most recent search:</p>";
                foreach ($search_recs as $val) {
                    $infostring = (!empty($val['ISSN'])?"ISSN: {$val['ISSN']}&nbsp;/&nbsp;":"").(!empty($val['DOI'])?"DOI: {$val['DOI']}&nbsp;/&nbsp;":"").(!empty($val['AN'])?"AN: {$val['AN']}":"");
                    echo "<p class=\"search-result\"><a target=\"_blank\"".generate_link(ezproxy_url($val['url']))."><span class=\"pointer\" style=\"text-decoration:none;\">&#0187;</span>".ssreplace(ucwords(strtolower($val['name'])),38)."<br/>"
                    . "<span style=\"text-decoration:none;\">$infostring&nbsp;</span></a></p>";
                }
            }
        }
    }
?>